This document describes and demonstrates analysis methods used to analyze mouse hippocampal subregion-specific transcriptome RNA-seq data (Farris et al manuscript in preparation.)

Raw sequence read data is provided through GEO GSE116343, with RNA-seq data available at GEO GSE116342. Data used for analysis in R is provided through an R package farrisdata, installed in R with devtools::install_github("jmw86069/farrisdata").

Description of Input Data

The input data for this analysis workflow is derived from Salmon quantitation files, which were already imported and assembled into relevant data matrices.

Gene expression data

Salmon quantitation files were imported using the R Bioconductor package tximport, summarized to the gene level, and stored in an R object farrisGeneSE, which is available in the R data package farrisdata, installed using devtools::install_github("jmw86069/farrisdata").

## Load the gene data
library(farrisdata);
library(SummarizedExperiment);
## Loading required package: GenomicRanges
## Loading required package: stats4
## Loading required package: BiocGenerics
## Loading required package: parallel
## 
## Attaching package: 'BiocGenerics'
## The following objects are masked from 'package:parallel':
## 
##     clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
##     clusterExport, clusterMap, parApply, parCapply, parLapply,
##     parLapplyLB, parRapply, parSapply, parSapplyLB
## The following object is masked from 'package:ade4':
## 
##     score
## The following objects are masked from 'package:dplyr':
## 
##     combine, intersect, setdiff, union
## The following objects are masked from 'package:stats':
## 
##     IQR, mad, sd, var, xtabs
## The following objects are masked from 'package:base':
## 
##     Filter, Find, Map, Position, Reduce, anyDuplicated, append,
##     as.data.frame, basename, cbind, colMeans, colSums, colnames,
##     dirname, do.call, duplicated, eval, evalq, get, grep, grepl,
##     intersect, is.unsorted, lapply, lengths, mapply, match, mget,
##     order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind,
##     rowMeans, rowSums, rownames, sapply, setdiff, sort, table,
##     tapply, union, unique, unsplit, which, which.max, which.min
## Loading required package: S4Vectors
## 
## Attaching package: 'S4Vectors'
## The following object is masked from 'package:gplots':
## 
##     space
## The following object is masked from 'package:plotly':
## 
##     rename
## The following objects are masked from 'package:dplyr':
## 
##     first, rename
## The following object is masked from 'package:base':
## 
##     expand.grid
## Loading required package: IRanges
## 
## Attaching package: 'IRanges'
## The following object is masked from 'package:plotly':
## 
##     slice
## The following objects are masked from 'package:dplyr':
## 
##     collapse, desc, slice
## Loading required package: GenomeInfoDb
## Loading required package: Biobase
## Welcome to Bioconductor
## 
##     Vignettes contain introductory material; view with
##     'browseVignettes()'. To cite Bioconductor, see
##     'citation("Biobase")', and for packages 'citation("pkgname")'.
## 
## Attaching package: 'Biobase'
## The following objects are masked from 'package:matrixStats':
## 
##     anyMissing, rowMedians
## Loading required package: DelayedArray
## Loading required package: BiocParallel
## 
## Attaching package: 'DelayedArray'
## The following objects are masked from 'package:matrixStats':
## 
##     colMaxs, colMins, colRanges, rowMaxs, rowMins, rowRanges
## The following objects are masked from 'package:base':
## 
##     aperm, apply
farrisGeneSE;
## class: SummarizedExperiment 
## dim: 49341 24 
## metadata(4): design contrasts genes samples
## assays(2): counts raw_counts
## rownames(49341): -343C11.2 00R_AC107638.2 ... n-TSaga9 n-TStga1
## rowData names(4): probeID ProbeName GeneName geneSymbol
## colnames(24): CA2CB492 CA2CB496 ... DGDE496 DGDE502
## colData names(4): CellType Compartment AnimalID groupName

farrisGeneSE SummarizedExperiment format

farrisGeneSE is a SummarizedExperiment object with this content:

  • assays list containing the numeric matrix with gene rows, sample columns, with log2 median-normalized counts. Each row is named using a unique gene symbol derived from the Gencode GTF file. To access the normalized TPM data:
assays(farrisGeneSE)[["counts"]]
  • assays also contains the raw Salmon pseudocounts accessible, using this command: assays(farrisGeneSE)[["raw_counts"]]

  • rowData data.frame with gene rows, using the gene symbol derived from the Gencode GTF file.

as.data.frame(head(rowData(farrisGeneSE), 10)) %>%
   mutate() %>%
   select(probeID, geneSymbol, ends_with("_type"),
      contains("has")) %>%
   kable(escape=FALSE) %>%
   kable_styling()
probeID geneSymbol
-343C11.2 -343C11.2 -343C11.2
00R_AC107638.2 00R_AC107638.2 00R_AC107638.2
00R_Pgap2 00R_Pgap2 00R_Pgap2
0610005C13Rik 0610005C13Rik 0610005C13Rik
0610006L08Rik 0610006L08Rik 0610006L08Rik
0610007P14Rik 0610007P14Rik 0610007P14Rik
0610009B22Rik 0610009B22Rik 0610009B22Rik
0610009E02Rik 0610009E02Rik 0610009E02Rik
0610009L18Rik 0610009L18Rik 0610009L18Rik
0610009O20Rik 0610009O20Rik 0610009O20Rik
  • colData annotated data.frame with sample rows, describing the mouse hippocampal Region, CellType, Sample, and groupName.
    CellType Compartment AnimalID groupName
    CA2CB492 CA2 CB 492 CA2_CB
    CA2CB496 CA2 CB 496
    CA2CB502 CA2 CB 502
    CA2DE492 CA2 DE 492 CA2_DE
    CA2DE496 CA2 DE 496
    CA2DE502 CA2 DE 502
    CA1CB492 CA1 CB 492 CA1_CB
    CA1CB496 CA1 CB 496
    CA1CB502 CA1 CB 502
    CA1DE492 CA1 DE 492 CA1_DE
    CA1DE496 CA1 DE 496
    CA1DE502 CA1 DE 502
    CA3CB492 CA3 CB 492 CA3_CB
    CA3CB496 CA3 CB 496
    CA3CB502 CA3 CB 502
    CA3DE492 CA3 DE 492 CA3_DE
    CA3DE496 CA3 DE 496
    CA3DE502 CA3 DE 502
    DGCB492 DG CB 492 DG_CB
    DGCB496 DG CB 496
    DGCB502 DG CB 502
    DGDE492 DG DE 492 DG_DE
    DGDE496 DG DE 496
    DGDE502 DG DE 502
    • metadata list describing the experimental design and contrasts used for statistical comparisons.
      • design numeric matrix describing the sample design, suitable for use directly by methods from the R Bioconductor limma package.
      • contrasts numeric matrix describing contrasts, suitable for use directly by limma.
      • samples vector of samples used.
      • genes vector of genes used.

Transcript expression data

Salmon quantitation files were imported using tximport as above, maintaining individual isoform abundances, then stored in an R object farrisTxSE, which is available in the R data package farrisdata, installed using devtools::install_github("jmw86069/farrisdata").

## Load the gene data
farrisTxSE;
## class: SummarizedExperiment 
## dim: 122733 24 
## metadata(4): design contrasts genes samples
## assays(4): tpm counts raw_tpm raw_counts
## rownames(122733): ENSMUST00000193812.1 ENSMUST00000082908.1 ...
##   ENSMUST00000189352.1 ENSMUST00000179623.1
## rowData names(10): transcript_id geneSymbol ... TxHasCDS
##   TxDetectedByTPM
## colnames(24): CA1CB492 CA1CB496 ... DGDE496 DGDE502
## colData names(4): CellType Compartment AnimalID groupName

farrisTxSE format

The farrisTxSE object is a named list with content similar to that described above for gene data:

  • assays list containing the numeric matrix with gene rows, sample columns, with log2 median-normalized counts. Each row is named using a unique gene symbol derived from the Gencode GTF file.
  • rowData data.frame with gene rows, using the gene symbol derived from the Gencode GTF file.
tx_df <- subset(as.data.frame(rowData(farrisTxSE)),
   geneSymbol %in% c("Gria1","Shank2","Ntrk2")) %>%
   select(geneSymbol,
      transcript_id,
      ends_with("_type"),
      contains("has"),
      contains("tpm"));
tx_df <- mixedSortDF(tx_df,
   byCols=match(c("geneSymbol","TxDetectedByTPM"),
     colnames(tx_df))*c(1,-1));
colorSubGene <- c(colorSub,
   group2colors(unique(tx_df$geneSymbol),
      cRange=c(20,30),
      lRange=c(80,90)));
tx_df2 <- kable_coloring(tx_df,
      colorSub=colorSubGene,
      row_color_by="geneSymbol",
      verbose=FALSE,
      returnType="kable") %>%
   collapse_rows(columns=2, valign="middle") %>%
   row_spec(0, background="#DDDDDD")

tx_df2;
geneSymbol transcript_id gene_type transcript_type has3UTR TxHas3UTR TxHasExt3UTR GeneHasExt3UTR TxHasCDS TxDetectedByTPM
ENSMUST00000036315.15 Gria1 ENSMUST00000036315.15 protein_coding protein_coding TRUE TRUE TRUE TRUE TRUE TRUE
ENSMUST00000094179.10 ENSMUST00000094179.10 protein_coding protein_coding TRUE TRUE TRUE TRUE TRUE TRUE
ENSMUST00000125292.1 ENSMUST00000125292.1 protein_coding protein_coding TRUE FALSE TRUE TRUE TRUE FALSE
ENSMUST00000151045.2 ENSMUST00000151045.2 protein_coding protein_coding TRUE TRUE TRUE TRUE TRUE FALSE
ENSMUST00000173531.1 ENSMUST00000173531.1 protein_coding processed_transcript TRUE FALSE FALSE TRUE FALSE FALSE
ENSMUST00000079828.5 Ntrk2 ENSMUST00000079828.5 protein_coding protein_coding TRUE TRUE TRUE TRUE TRUE TRUE
ENSMUST00000109838.8 ENSMUST00000109838.8 protein_coding protein_coding TRUE TRUE TRUE TRUE TRUE TRUE
ENSMUST00000105900.8 Shank2 ENSMUST00000105900.8 protein_coding protein_coding TRUE TRUE TRUE TRUE TRUE TRUE
ENSMUST00000146006.2 ENSMUST00000146006.2 protein_coding protein_coding TRUE TRUE TRUE TRUE TRUE TRUE
ENSMUST00000097929.3 ENSMUST00000097929.3 protein_coding protein_coding TRUE TRUE TRUE TRUE TRUE FALSE
ENSMUST00000105902.7 ENSMUST00000105902.7 protein_coding protein_coding TRUE TRUE TRUE TRUE TRUE FALSE
ENSMUST00000136979.1 ENSMUST00000136979.1 protein_coding processed_transcript TRUE FALSE FALSE TRUE FALSE FALSE
ENSMUST00000213146.1 ENSMUST00000213146.1 protein_coding protein_coding TRUE FALSE TRUE TRUE TRUE FALSE
  • colData annotated data.frame with sample rows, describing the mouse hippocampal Region, CellType, Sample, and groupName. This data is identical to the sample table shown for farrisGeneSE above.
  • metadata list describing the experimental design and contrasts used for statistical comparisons.
    • design numeric matrix describing the sample design, suitable for use directly by methods from the R Bioconductor limma package.
    • contrasts numeric matrix describing contrasts, suitable for use directly by limma.
    • samples vector of samples used.
    • genes vector of genes used.

Gene expression analysis summary

BGA plot

bgaExprs <- assays(farrisGeneSE)$counts;
bgaExprs[bgaExprs < 7] <- 7;
bgaExprsUse <- bgaExprs[rowMins(bgaExprs) < rowMaxs(bgaExprs),,drop=FALSE];
nrow(bgaExprsUse);
## [1] 18005
salmonBga1 <- bga(dataset=bgaExprsUse,
   classvec=nameVector(colData(farrisGeneSE)$groupName,
      colnames(farrisGeneSE)),
   type="coa");
salmonBga1ly <- bgaPlotly3d(salmonBga1,
   axes=c(1,2,3),
   colorSub=colorSub,
   useScaledCoords=FALSE,
   drawVectors="none",
   drawSampleLabels=FALSE,
   superGroups=gsub("_.+", "", salmonBga1$fac),
   ellipseType="none",
   sceneX=0, sceneY=1, sceneZ=1,
   verbose=FALSE);
salmonBga1ly;
## Warning in verify_mode(p): A textfont object has been specified, but text is not in the mode
## Adding text to the mode...
# sys.source("/Users/wardjm/Projects/R-scripts/bga_functions.R", envir=bga_env, keep.source=TRUE);
# attach(bga_env);detach(pos=tail(igrep("bga_env", search()), -1));

Comparison with CA1 published data by Nakayama, Ainsley, Cajigas

First we calculate group medians using gene expression data, to determine the set of genes detected above an expression threshold of 128 pseudocounts (log2 = 7).

farrisGeneGroupMedians <- rowGroupMeans(assays(farrisGeneSE)[["counts"]],
   groups=colData(farrisGeneSE)$groupName,
   useMedian=TRUE);

# Plot histogram of expression in CA1_CB and CA1_DE
plotPolygonDensity(farrisGeneGroupMedians[,c("CA1_CB","CA1_DE")],
   xlim=c(0,20),
   ylim=c(0,700),
   ablineV=7);
## Warning in hist.default(x, breaks = breaks, col = barCol, main = main,
## border = histBorder, : arguments 'col', 'border', 'main', 'xlim', 'ylab',
## '...' are not made use of
## Warning: In density.default(x, width = width, weight = rep(weightFactor, 
##     length.out = length(x)), ...) :
##  extra argument 'xlim' will be disregarded
## Warning in rep(weightFactor, length.out = length(x)): 'x' is NULL so the
## result will be NULL
## Warning in hist.default(x, breaks = breaks, col = barCol, main = main,
## border = histBorder, : arguments 'col', 'border', 'main', 'xlim', 'ylab',
## '...' are not made use of
## Warning: In density.default(x, width = width, weight = rep(weightFactor, 
##     length.out = length(x)), ...) :
##  extra argument 'xlim' will be disregarded
## Warning in rep(weightFactor, length.out = length(x)): 'x' is NULL so the
## result will be NULL

# Detected genes in CA1_CB and CA1_DE
CA1detected <- (farrisGeneGroupMedians[,"CA1_CB"] > 7 &
   farrisGeneGroupMedians[,"CA1_DE"] > 7);
CA1detCBandDE <- rownames(farrisGeneGroupMedians)[CA1detected];
length(CA1detCBandDE);
## [1] 10877

Next we load previously gene lists representing detected CA1 dendrite genes from published studies from Nakayama et al, Ainsley et al, and Cajigas et al. These genes are available in the farrisdata package, as described above.

Produce a 4-way Venn diagram showing the overlapping genes from these studies.

GeneListL <- list(
  Farris=CA1detCBandDE,
  Cajigas=CajigasGenes,
  Ainsley=AinsleyGenes,
  Nakayama=NakayamaGenes);
GeneListIM <- list2im(GeneListL);
vps <- limma::vennDiagram(GeneListIM,
   circle.col=rainbowJam(4));

vps2 <- venn(GeneListL,
   show.plot=FALSE);
## Retrieve specific overlaps like this:
vps2vennL <- attr(vps2, "intersections");
## vps2vennL[["Farris:Cajigas:Ainsley:Nakayama"]]

Correlation Centered by Compartment, refers to Figure 2

Cell Body

Per-sample correlation, centered across all CB samples. First, we use Salmon normalized pseudocounts, restricted to genes where at least one group mean value is above log2(7), which is >= 128 normalized pseudocounts.

Then data is centered per Compartment, so that CellBody samples are centered by subtracting the mean CellBody expression per gene, and Dendrite samples are centered by subtracting the mean Dendrite expression per gene. This step uses centerGeneData() with the argument centerGroups.

Next we prepare a data.frame with color coding to show the CellType and Compartment values.

## farrisGeneGroupMedians
## Pull out only cell body samples
iSamples <- colnames(farrisGeneSE);
iSamplesCB <- vigrep("CB", iSamples);
iSamplesDE <- vigrep("DE", iSamples);
#iSamplesGrp <- colnames(iMatrix7grp);
iSamplesGrp <- colnames(farrisGeneGroupMedians);
iSamplesGrpCB <- vigrep("CB", iSamplesGrp);
iSamplesGrpDE <- vigrep("DE", iSamplesGrp);

corrCutoff <- 7;
genesAboveCutoff <- (rowMaxs(farrisGeneGroupMedians) >= corrCutoff);
genesAboveCutoffCB <- (rowMaxs(farrisGeneGroupMedians[,iSamplesGrpCB]) >= corrCutoff);
genesAboveCutoffDE <- (rowMaxs(farrisGeneGroupMedians[,iSamplesGrpDE]) >= corrCutoff);
genesAboveCutoffBoth <- (genesAboveCutoffCB & genesAboveCutoffDE);

iMatrix7 <- assays(farrisGeneSE[genesAboveCutoff,])[["counts"]];
centerGroups <- gsub("^.+(DE|CB).+$",
   "\\1",
   iSamples);
iMatrix7ctr <- centerGeneData(iMatrix7,
   centerGroups=centerGroups);
iMatrix7ctrCor <- cor(iMatrix7ctr);


## Generate some color bars to annotate the heatmap
colDataColorsRepL <- as.data.frame(colData(farrisGeneSE)[,c("CellType","Compartment")]);
colDataColorsRep <- df2colorSub(colDataColorsRepL, colorSub=colorSub);

Heatmap using ComplexHeatmap:

pheat_colors <- list(Compartment=colorSub[c("CB","DE")],
   CellType=colorSub[c("CA1","CA2","CA3","DG")]);
pheat_breaks <- warpAroundZero(seq(from=-1, to=1, length.out=51), lens=1);

cBR <- circlize::colorRamp2(breaks=pheat_breaks,
   col=getColorRamp("RdBu_r", n=51));
## Warning in brewer.pal(n, col): n too large, allowed maximum for palette RdBu is 11
## Returning the palette you asked for with that many colors
colHA <- HeatmapAnnotation(colDataColorsRepL[iSamplesCB,2:1],
   show_annotation_name=TRUE,
   col=pheat_colors);
rowA <- rowAnnotation(colDataColorsRepL[iSamplesCB,2:1],
   col=pheat_colors,
   show_annotation_name=TRUE,
   show_legend=FALSE);

corHM <- Heatmap(iMatrix7ctrCor[iSamplesCB,iSamplesCB],
   name="Correlation",
   clustering_method_columns="ward.D",
   clustering_method_rows="ward.D",
   column_dend_height=unit(20, "mm"),
   row_dend_width=unit(20, "mm"),
   top_annotation=colHA,
   col=cBR);
draw(rowA + corHM, row_dend_side="left");

if (1 == 2) {
   ## For now, commenting out custom heatmap function
   par("family"="Arial", "lend"="square", "ljoin"="mitre");
   heatmap.3(iMatrix7ctrCor[iSamplesCB,iSamplesCB],
      margins=c(15,15),
      trace="none",
      tracecol="transparent",
      col=colorRampPalette(rev(brewer.pal(15,"RdBu")))(51),
      add.expr=box(),
      cexCol=1.5,
      cexRow=1.5,
      keyLabel="Correlation",
      colLensFactor=10,
      distMethod="euclidean",
      hclustMethod="ward",
      doColorDendrograms=TRUE,
      ColSideColors=t(colDataColorsRep[iSamplesCB,2:1]),
      ColSideColorsNote=t(colDataColorsRepL[iSamplesCB,2:1]),
      RowSideColors=(colDataColorsRep[iSamplesCB,2:1]),
      RowSideColorsNote=(colDataColorsRepL[iSamplesCB,2:1]) );
}

Cell Body and Dendrite

Correlation showing CA2_CB correlates highest with CA2_DE, etc. for each CellType.

## farrisGeneGroupMedians[genesAboveCutoff,]
iMatrix7grp <- farrisGeneGroupMedians[genesAboveCutoffCB,];
centerGroupsGrp <- gsub("^.*(DE|CB).*$",
   "\\1",
   iSamplesGrp);
## 31oct2018 using mean instead of median
iMatrix7grpCtr <- centerGeneData(iMatrix7grp,
   centerGroups=centerGroupsGrp,
   mean=TRUE);
iMatrix7grpCtrCor <- cor(iMatrix7grpCtr);

## Generate some color bars to annotate the heatmap
colDataColorsGrpL <- data.frame(rbindList(
   strsplit(nameVector(iSamplesGrp), "_")));
colnames(colDataColorsGrpL) <- c("CellType","Compartment");
colDataColorsGrp <- df2colorSub(colDataColorsGrpL,
  colorSub=colorSub);

Heatmap using ComplexHeatmap:

colHA2 <- HeatmapAnnotation(colDataColorsGrpL[iSamplesGrp,2:1],
   show_annotation_name=TRUE,
   col=pheat_colors);
rowA2 <- rowAnnotation(colDataColorsGrpL[iSamplesGrp,2:1],
   col=pheat_colors,
   show_annotation_name=TRUE,
   show_legend=FALSE);

corHM2 <- Heatmap(iMatrix7grpCtrCor[iSamplesGrp,iSamplesGrp],
   name="Correlation",
   clustering_method_columns="ward.D",
   clustering_method_rows="ward.D",
   column_dend_height=unit(20, "mm"),
   row_dend_width=unit(20, "mm"),
   top_annotation=colHA2,
   col=cBR);
draw(rowA2 + corHM2, row_dend_side="left");

Splom plot, refers to Figure 2, and Supplemental Figure 3

Scatterplot showing the +1,+1 selection of genes, which helps define the gene lists in the next section.

corCols <- c("CA2_DE","CA2_CB");
cutCB <- round(digits=3, log2(1.5));
cutDE <- round(digits=3, log2(1.5));
splomL <- lapply(nameVector(c("CA1","CA2","CA3","DG")), function(k) {
   corCols <- vigrep(k, colnames(iMatrix7grpCtr));
   df1 <- as.data.frame(iMatrix7grpCtr[,corCols]);
   CBhit <- (abs(df1[,1]) > cutCB) * sign(df1[,1]);
   DEhit <- (abs(df1[,2]) > cutCB) * sign(df1[,2]);
   CBhitN <- paste0(k, "_", "CBhit");
   DEhitN <- paste0(k, "_", "DEhit");
   df1[,CBhitN] <- CBhit;
   df1[,DEhitN] <- DEhit;
   df1[,"GeneName"] <- rownames(df1);
   df1;
});
#table(splomL[[1]][,3:4])
splomLsub <- lapply(splomL, function(iDF){
   subset(iDF, !iDF[,3] %in% 0 | !iDF[,4] %in% 0)
});

splomDF2 <- rbindList(lapply(splomLsub, function(iDF){
   iDF[,"CellType"] <- gsub("_.+", "", colnames(iDF)[1]);
   colnames(iDF) <- c("CB","DE","CBhit","DEhit","GeneName","CellType");
   iDF;
}));
#splomDF2[,"row"] <- ifelse(splomDF2$CellType %in% c("CA1","CA2"), "CA1", "CA3");
splomDF2[,"CBDEhit"] <- paste0(splomDF2$CBhit,":",splomDF2$DEhit);

## Color-code the splom points
ccColors <- nameVector(rep("grey", 8), unique(splomDF2$CBDEhit));
ccColors[c("1:1","-1:-1")] <- "orangered3";
ccColors[c("-1:1","1:-1")] <- "grey";

## Gene labels
GeneHighlight <- c("Plch2","Rgs14","Necab2","1700024P16Rik");
splomDF2$label <- ifelse(splomDF2$GeneName %in% GeneHighlight,
  splomDF2$GeneName, "");


splomDF2[,"CBmaxGroupMean"] <- rowMaxs(farrisGeneGroupMedians[splomDF2$GeneName,iSamplesGrpCB]);
splomDF2[,"DEmaxGroupMean"] <- rowMaxs(farrisGeneGroupMedians[splomDF2$GeneName,iSamplesGrpDE]);
splomDF2[,"CBdet7"] <- (splomDF2[,"CBmaxGroupMean"] > 7)+0;
splomDF2[,"DEdet7"] <- (splomDF2[,"DEmaxGroupMean"] > 7)+0;

gg2 <- ggplot(splomDF2,
      aes(x=CB, y=DE, color=CBDEhit, fill=CBDEhit, GeneName=GeneName)) +
   geom_point(shape=21, size=2) +
   geom_vline(xintercept=c(-1,1)*0.585,
      linetype="dashed", color="grey20") +
   geom_hline(yintercept=c(-1,1)*0.585, linetype="dashed", color="grey20") +
   facet_wrap(facets=~CellType) +
   theme_jam() +
   scale_fill_manual(values=ccColors) +
   scale_color_manual(values=makeColorDarker(ccColors)) +
   ggrepel::geom_label_repel(aes(label=label),
      force=8,
      fill="white") +
   theme(legend.position="none");
gg2;

Microarray correlation heatmap.

Neuronal Gene Lists

(Description of the four gene/transcript lists)

## anyGenes1 is the full set of all genes with abundance > 1
anyGenes1 <- rownames(farrisGeneGroupMedians)[rowMaxs(farrisGeneGroupMedians) > 1];

## Filtering rules for CB and DE
corFilterRuleCB <- (rowMaxs(farrisGeneGroupMedians[,iSamplesGrpCB]) >= 7);
corFilterRuleDE <- (rowMaxs(farrisGeneGroupMedians[,iSamplesGrpDE]) >= 7);
corFilterRule <- (corFilterRuleCB);

DEgenes7 <- rownames(farrisGeneGroupMedians)[corFilterRuleDE];
CBgenes7 <- rownames(farrisGeneGroupMedians)[corFilterRuleCB];
DEgenes7nonCB7 <- setdiff(DEgenes7, CBgenes7); # non-pyramidal
CBgenes7nonDE7 <- setdiff(CBgenes7, DEgenes7); # "non-DE genes"
DEgenes7andCB7 <- intersect(DEgenes7, CBgenes7);   # "DE genes"

## Define neuro gene lists
geneListsAll <- list(anyGenes1=anyGenes1,
   DEandCB=DEgenes7andCB7, # detected
   CBonly=CBgenes7nonDE7,  # detected only CB, not detected DE
   `non-pyramidal`=DEgenes7nonCB7,
   `CB1andDE1`=unique(subset(splomDF2,
      CBDEhit %in% "1:1" &
      CBdet7 %in% c(1) &
      DEdet7 %in% c(1))$GeneName)
   );
#lengths(geneListsAll);
geneListsDF <- data.frame(GeneList=names(geneListsAll),
   GeneCount=format(lengths(geneListsAll), big.mark=",", trim=TRUE));
rownames(geneListsDF) <- NULL;
geneListsDF2 <- kable_coloring(geneListsDF,
      colorSub=group2colors(names(geneListsAll)),
      row_color_by="GeneList",
      returnType="kable") %>%
   row_spec(0, background="#DDDDDD")
geneListsDF2;
GeneList GeneCount
anyGenes1 28,075
DEandCB 12,265
CBonly 548
non-pyramidal 1,871
CB1andDE1 1,055

Heatmap per-gene.

Differential gene expression using limma

Transcript analysis summary

Definition of “detected transcripts”

We refer to the function defineDetectedTx() in the jampack R package. The function takes normalized counts, normalized TPM values, sample group information, and several cutoff values:

  • cutoffTxPctMax=10 requires a transcript isoform to be at least 10% of the highest isoform present in the same sample.
  • cutoffTxExpr=32 requires a transcript isoform to have at least 32 normalized counts.
  • cutoffTxTPMExpr=2 requires a transcript isoform to have at least a TPM value of 2.
  • All of the above criteria must be met for an isoform to be considered “detected.”
#refreshFunctions("farrisSalmonWWS");
#detectedTxTPML <- try(defineDetectedTx(
detectedTxTPML <- defineDetectedTx(
   iMatrixTx=assays(farrisTxSE)[["counts"]],
   iMatrixTxTPM=assays(farrisTxSE)[["tpm"]],
   groups=colData(farrisTxSE)$groupName,
   cutoffTxPctMax=10,
   cutoffTxExpr=32,
   cutoffTxTPMExpr=2,
   tx2geneDF=renameColumn(rowData(farrisTxSE),
     from=c("geneSymbol","probeID"),
     to=c("gene_name","transcript_id")),
   useMedian=FALSE,
   verbose=FALSE);
detectedTx <- detectedTxTPML$detectedTx;
numDetectedTx <- length(detectedTx);
detectedGenes <- mixedSort(unique(rowData(farrisTxSE[detectedTx,])$geneSymbol));
numDetectedGenes <- length(detectedGenes);

The code above defined 27,759 detected transcripts by the given criteria, covering 13,951 unique gene symbols.

Transcript type per gene list

e.g. protein_coding, etc.

First, as a point of organizing the transcript-gene associations, we read the Gencode GTF file and produce a data.frame with the transcript-gene data.

Note: This step downloads the Gencode GTF file for version vM12, then extracts data from that file. Once the data.frame is extracted, it is stored in a text file for re-use.

vM12gtf <- "ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_mouse/release_M12/gencode.vM12.annotation.gtf.gz";
vM12gtfBase <- basename(vM12gtf);
if (!file.exists(vM12gtfBase)) {
   curl::curl_download(url=vM12gtf,
      destfile=vM12gtfBase);
}
tx2geneFile <- file.path(".", "vM12gtf.tx2geneDF.txt");
if (!file.exists(tx2geneFile)) {
   tx2geneDF <- makeTx2geneFromGtf(GTF=vM12gtfBase,
      verbose=FALSE);
   write.table(file=tx2geneFile,
      x=tx2geneDF,
      sep="\t",
      quote=FALSE,
      na="",
      col.names=TRUE,
      row.names=FALSE);
} else {
   tx2geneDF <- read.table(tx2geneFile,
      sep="\t",
      check.names=FALSE,
      as.is=TRUE,
      fill=TRUE,
      quote="\"",
      allowEscapes=FALSE,
      comment.char="",
      header=TRUE,
      stringsAsFactor=FALSE);
}

Analysis of 3’UTR length

We imported Gencode vM12 comprehensive GTF into R using R Bioconductor GenomicFeatures package, with which we derived 3’UTR regions, using GenomicFeatures::makeTxDbFromGFF() and GenomicFeatures::threeUTRsByTranscript(), respectively.

This step re-uses the Gencode GTF file downloaded above, then converts it to a “Txdb” object, which is a SQLite relational database format. This database is saved into a file so it can be recalled without re-creating the file again.

localDb <- file.path(".", "vM12gtf.txdb");
if (!file.exists(localDb)) {
   vM12txdb <- GenomicFeatures::makeTxDbFromGFF(vM12gtfBase);
   AnnotationDbi::saveDb(x=vM12txdb, file=localDb);
} else {
   vM12txdb <- AnnotationDbi::loadDb(file=localDb);
}
## Loading required package: GenomicFeatures
## Loading required package: AnnotationDbi
## 
## Attaching package: 'AnnotationDbi'
## The following object is masked from 'package:plotly':
## 
##     select
## The following object is masked from 'package:dplyr':
## 
##     select
gencode3utr <- GenomicFeatures::threeUTRsByTranscript(vM12txdb,
   use.names=TRUE);
values(gencode3utr@unlistData)[,"transcript_id"] <- rep(names(gencode3utr), lengths(gencode3utr));
values(gencode3utr@unlistData)[,"gene_id"] <- tx2geneDF[values(gencode3utr@unlistData)[,"transcript_id"],"gene_id"];
values(gencode3utr@unlistData)[,"gene_name"] <- tx2geneDF[values(gencode3utr@unlistData)[,"transcript_id"],"gene_name"];
values(gencode3utr@unlistData)[,"gene_type"] <- tx2geneDF[values(gencode3utr@unlistData)[,"transcript_id"],"gene_type"];
values(gencode3utr@unlistData)[,"transcript_type"] <- tx2geneDF[values(gencode3utr@unlistData)[,"transcript_id"],"transcript_type"];
names(gencode3utr@unlistData) <- pasteByRow(values(gencode3utr@unlistData)[,c("transcript_id","exon_rank")]);

We plotted 3’UTR lengths as violin plots using only detected transcripts based upon TPM criteria described elsewhere.

Translational Efficiency using CAI

Proximal-Distal 3’UTR Analysis

Differential transcript isoform analysis limma

Splicing, Sashimi plots

Gene Set Enrichment, MultiEnrichMap

Selection of gene hits

Used DESeq-normalized expression values.

Hypergeometric enrichment using MSigDB v6.0

Preparing MSigDB v6.0 data

Creating gmtT format, refreshing gene symbols in the gmtT data, and the RNAseq gene hit data to be fully in sync.

Commentary on alt gene symbols, conversion to official mouse Entrez gene symbols.

enrichSimple

Wrapper around standard hypergeometric enrichment tests, with a custom background of detected genes.

MultiEnrichMap

Subset pathways for top 15 per source-category

Heatmap of enrichment P-values.

Cnet plot